<?php
    include("../includes/config.php");
    include("../includes/connection.php");
    include("../includes/database.php");

    include("authenticate.php");
    
    $title = "Add Post";
    
    include("header.php")
?>

<h1>Add New Post</h1>

<form action="<?php echo $CONFIG["base_url"] ?>admin/save-post.php?action=add" method="POST">
    <label>Title</label>
    <input type="text" name="title"/>
    
    <label>Category</label>
    <select name="category_id">
        <?php 
            $categories = getAllCategories();
            while ($category = mysql_fetch_assoc($categories)) {
        ?>        
        <option value="<?php echo $category["id"] ?>"><?php echo $category["name"] ?></option>
        <?php
            }
        ?>
    </select>
    
    <script>
        $(function(){
            $(".datepicker").datepicker();
        });
    </script>
    
    <label>Published Time</label>
    <input class="datepicker" type="text" name="published_time"/>
    
    <label>Excerpt</label>
    <textarea name="excerpt"></textarea>
    
    <label>Content</label>
    <textarea name="body"></textarea>
    
    <input type="hidden" name="author_id" value="<?php echo $_SESSION["user_id"]; ?>"/>
    
    <br/>
    <input type="submit" value="Save" class="btn btn-primary"/>
</form>

<?php 
    include ("footer.php");
?>